	#include("/common/include/include.html")
<style>
	.breadcrumb li{
		float:left;
	}
</style>
<div class="admin-main">
	<blockquote class="layui-elem-quote">
					<span>主页<span><span>/</span><a href="#(ctx??)/admin/operate/getListPage">功能管理</a><span>/</span><span class="curr">功能</span>
	</blockquote>
	<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
		<legend>添加新功能</legend>
	</fieldset>

	<form class="layui-form" >
		<div class="layui-form-item">
			<label class="layui-form-label">所属模块</label>
			<div class="layui-input-inline">
				<input type="text" id="moduleName" value="#(module?module.name:'根目录')"  class="layui-input">
				<input type="hidden" id="moduleId" name="sysOperate.module_id" value="#(oper?oper.module_id:'#root')" lay-verify="title" lay-verify="required"  class="layui-input">
				<input type="hidden" name = "sysOperate.id" value="#(oper?oper.id:'')">
			</div>
			<div class="layui-input-inline">
				<a class="layui-btn layui-btn-small" onclick="selectModule()">选择</a>
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">名称</label>
			<div class="layui-input-inline">
				<input type="text" name="sysOperate.name" value="#(oper?oper.name:'')"  placeholder="请输入名称" lay-verify="name" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">地址</label>
			<div class="layui-input-inline">
				<input type="text" name="sysOperate.url" value="#(oper?oper.url:'')" placeholder="请输入地址" lay-verify="title" lay-verify="required" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">排序</label>
			<div class="layui-input-inline">
				<input type="text" name="sysOperate.sort" value="#(oper?oper.sort:'0')"  placeholder="请输入排序号" lay-verify="sort" lay-verify="required"  class="layui-input">
			</div>
		</div>
		<div class="layui-form-item layui-form-text">
			<label class="layui-form-label">描述信息</label>
			<div class="layui-input-block">
				<textarea placeholder="请输入内容" class="layui-textarea" name="sysOperate.description">#(oper?oper.description:'')</textarea>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button class="layui-btn" lay-submit="" lay-filter="submitFormFilter">保存</button>
				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
			</div>
		</div>
	</form>
</div>

<script>
layui.config({
	  base: ctx+'/common/js/'
}).use(['form','ajax'], function(){
		 var form = layui.form();
		 form.verify({
				title: function(value) {
					if(value.length > 50){
						return '最多50个字符!';
					}
				},
				name: function(value){
					if(value.length<=2){
						return '请填写至少两个字符的名称!';
					}
				}
		 });
		 form.on('submit(submitFormFilter)', function(data) {
			var d = ajax.ajaxFunc(ctx+"/admin/operate/save",data.field,"json",null);
			if(d.success){
				parent.layer.alert(d.message);
				window.location.href=ctx+"/admin/operate/getListPage";				
			}else{
				parent.layer.alert(d.message);
			}
			return false;
		});
});
function selectModule(){
	parent.layer.open({
	  type: 2, 
	  title:"选择父级模块",
	  area: ['300px', '400px'],
	  content: ctx+'/admin/module/getSelectPage'
	}); 
}
function setSelectedParent(data){
	$("#moduleId").val(data.id);
	$("#moduleName").val(data.name);
}
</script>